#ifndef NOOPPROGRESS_H
#define NOOPPROGRESS_H

#include <ed_core/global/progresshandler.h>

namespace ed_core_private
{

class NoopProgress: public ed_core::ProgressHandler
{
public:
  void finished() {}
  void error(const QString&) {}
  void progress(int,int) {}
  void message(const QString&) {}
};

#define CHECK_PROGRESS(var)\
bool __delete_##var##__ = (var == nullptr);\
if (__delete_##var##__) var = new ed_core_private::NoopProgress();\
struct __##var##__remover__ {\
  bool del_##var;\
  ed_core::ProgressHandler* p_##var;\
  __##var##__remover__(bool d,ed_core::ProgressHandler* h) : del_##var(d), p_##var(h) {}\
  virtual ~__##var##__remover__() { if (del_##var) delete p_##var; }\
} __##var##_remover__(__delete_##var##__, var)

} // namespace ed_core_private

#endif // NOOPPROGRESS_H

